package com.qf.admin.controller;

import com.qf.common.http.Result;
import com.qf.entity.dto.Admin;
import com.qf.entity.po.LoginAdmin;
import com.qf.entity.vo.JqueryTreeView;
import com.qf.service.impl.AdminModuleService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class IndexController {

    @Resource
    AdminModuleService adminModuleService;

    @RequestMapping("index")
    public String toIndex(Model model, LoginAdmin admin){
        model.addAttribute("name",admin.getName());
        return "index";
    }

    @RequestMapping("func-list")
    @ResponseBody
    public Result<List<JqueryTreeView>> getModuleList(LoginAdmin admin) {
        return Result.success(adminModuleService.getModuleByAdminId(admin.getId()));
    }
}
